<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    用户名:<input type="text" name="username" id="username"></br>
        密码:<input type="text" name="pwd" id="pwd"></br>
        文件上传:<input type="file" name="myimg" id="myimg"></br>
        <input type="submit"  id="btn">
        <script>
            let xhr;
            if(window.XMLHttpRequest){
                xhr=new XMLHttpRequest;
            }
            else{
                xhr=new ActiveXObject;
            }
            document.querySelector("#btn").onclick=function(){
                let username=document.querySelector("#username").value;
                let pwd=document.querySelector("#pwd").value;
                console.log(typeof pwd)
                xhr.open("post","deal.php",true);
                xhr.setRequestHeader("content-type","application/x-www-form-urlencoded")
                xhr.send(`username=${username}&pwd=${pwd}`);
                xhr.onload=function(){
                    console.log(JSON.parse(xhr.responseText));
                }
            }
        </script>
</body>
</html>